
{include file="public_iframe:head"}
<script src="__STATIC__/laydate/laydate.js"></script>

<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="ibox float-e-margins">
        <div class="ibox-title">
            <h5>任务审核</h5>
            <div class="ibox-tools" style="margin-top: -9px;">
                <a href="javascript:location.reload();" class="btn btn-primary"><i class="fa fa-refresh"></i> 刷新</a>
            </div>
        </div>
        <div class="ibox-content">
        <div class="row row-lg">
                <div class="col-sm-12">
                   <!--  <h4 class="example-title"></h4>
                    <a class="btn btn-primary" href="{:url('Mission/edit_mission')}">添加内容</a>
                    <br/> -->
                    <div>
                        <form action="" style="display: initial;">
                            <div class="col-sm-1 pull-left" style="width: 250px;">
                                <input class="form-control" placeholder="手机号搜索" name="phone" type="text" value="{$phone?$phone:''}">
                            </div>
                            <button class="btn btn-primary" id="select"> 
                                <i class="glyphicon glyphicon-search"></i>
                                查询
                            </button>
                        </form>
                        <button class="btn btn-primary examine" id="pass" style="margin-left: 20px;margin-right: 5px;" value="2">一键审核通过</button>
                        <button class="btn btn-danger examine" id="noPass" value="3">一键审核不通过</button>
                    </div>
                    <div class="table-responsive">
                        <!--class="table table-bordered table-hover"-->
                        <table data-toggle="table" class="table table-bordered table-hover"
                        >
                                <thead>
                                <tr  style="background: #f9f9f9;">
                                    <th><input  class="checkAll" type="checkbox" /></th>
                                    <th>编号</th>
                                    <th>用户ID</th>

                                    <th>用户</th>
                                    <th>审核状态</th>
                                    <th>任务内容</th>
                                    
                                    <th>图片</th>
                                    <th>佣金</th>
                                    <th>提交时间</th>
                                    <th>操作</th>
                                </tr>
                                </thead>
                                <tbody>
                                {volist name="list" id="vo"}
                                <tr>
                                    <td><input class="checkbox" type="checkbox" name="users_id[]" value="{$vo['id']}" /></td>
                                    <td>{$vo.id}</td>
                                    <td>{$vo.uid?$vo.uid:''}</td>
                                    <th>{$vo.account?$vo.account:''}</th>
                                    <td>

                                        {switch name="$vo.status"}
                                            {case value="1"}待审核{/case}
                                            {case value="2"}审核通过{/case}
                                            {case value="3"}审核不通过{/case}
                                            {default /}
                                        {/switch}
                                    </td>
                                    <td>{$vo.content}</td>
                                   <!--  <td>{$vo.task_record_id}</td> -->
                                    <td style="width: 400px;">
                                        {if condition="!empty($vo.img_array)"}
                                            {volist name="$vo.img_array" id="img"}
                                            <img alt="image" style="width:60px;height:60px;" class="" src="{$img['task_img']}">
                                            {/volist}
                                        {/if}
                                    </td>
                                    <td>{$vo.money}</td>
                                    <td>{$vo.created_at|date="Y-m-d H:i:s",###}</td>
                                    <td class="center" width="180">
                                          {switch name="$vo.status"}
                                            {case value="1"}
                                                <a href="{:url('Mission/edit_examine',array('id'=>$vo['id']))}" class="btn btn-primary">查看审核</a>
                                            {/case}
                                            {case value="2"}
                                                <a href="#" class="btn btn-primary">审核通过</a>
                                            {/case}
                                          
                                            {default /}
                                        {/switch}
                                        
                                        <a href="#" class="btn btn-danger" id="btn-danger" data-id="{$vo.id}" >删除</a>
                                    </td>
                                </tr>
                                {/volist}
                                </tbody>
                                <!-- <input type="submit" id="test2" name="" onclick=""> -->
                        </table>
                    </div>
                </div>
                <div class="col-sm-12">
                    <!-- Example Pagination -->
                    <ul class="pagination  pull-right">
                        {$page}
                    </ul>
                    <!-- End Example Pagination -->
                </div>
            </div>
        </div>
    </div>
    <!-- End Panel Basic -->
</div>

<!-- 全局js -->
<script src="__STATIC__/admin/js/jquery.min.js?v=2.1.4"></script>
<script src="__STATIC__/admin/js/bootstrap.min.js?v=3.3.6"></script>

<script>

    //时间选择器
   //时间选择器
    laydate.render({
      elem: '#test1'
      ,type: 'datetime'
    });
    var list = [];
    $('.checkbox').click(function(){
        if ($(this).hasClass('on')) {
            $(this).removeClass('on');
            $('.checkAll').removeClass('on');
            $('.checkAll').prop('checked',false);
        }else {
            var allCheckNum = $("input[type='checkbox']").length;
            var checkedNum = $("input[type='checkbox']:checked").length;
            $(this).addClass('on');
            $('.checkAll').addClass('on');
            if ((allCheckNum-1) == checkedNum){
                $('.checkAll').prop('checked',true);
            };
        }
    });
    $('.checkAll').click(function(){
        var allCheckNum = $("input[type='checkbox']").length;
        var checkedNum = $("input[type='checkbox']:checked").length;
        if ($(this).hasClass('on')){
            $('.checkbox').prop('checked',false);
            $('.checkbox').removeClass('on');
            $(this).removeClass('on');
        }else {
            $('.checkbox').prop('checked',true);
            $('.checkbox').addClass('on');
            $(this).addClass('on');
        }
    });
        

    $('.examine').click(function(){
        var id = '';
        var length = $(".checkbox:checked").length;
        var status = $(this).attr('value');
        for(var i = 0;i < length;i++){
            var value = $(".checkbox:checked").eq(i).val();
            if (i == 0){
                id =  value;
            }else {
                id =  id + ',' + value;
            }
        }
        var data = {
            'id': id,
            'status': status
        };
       /* console.log(data);*/
       $.post("{:url('Mission/updateall')}",data,function(result) {
                console.log(result);
                if(result.code == '0'){
                    parent.layer.alert(result.msg);
                }else{
                    parent.layer.msg(result.msg,{
                                icon:1,
                                time:1000,
                            },
                            function (index, item) {
                                window.location.href="{:url('Mission/examine_mission')}";
                            });
                }
            });
    });   
/*        $.ajax({
            url:"{:url('Mission/updateall')}",
            type:'POST',
            data:data,
            async:false,
            processData:false,
            contentType:false,
            success:function(result) {
                console.log(result);
                if(result.code == '0'){
                    parent.layer.alert(result.msg);
                }else{
                    parent.layer.msg(result.msg,{
                                icon:1,
                                time:1000,
                            },
                            function (index, item) {
                                window.location.href="{:url('Mission/examine_mission')}";
                            });
                }
            }
        });
    });*/

</script>
<script>

    //删除
    $(".btn-danger").click(function(){
        var id = $(this).data('id');
        parent.layer.confirm('删除数据无法恢复，并且会影响用户数据，确定删除？', {
            shade:false,
            btn: ['确定', '取消']
        }, function() {
            $.post("{:url('Mission/delexamine')}", {id: id}, function (result) {
                if (result.code == '0') {
                    parent.layer.alert(result.msg);
                } else {
                    parent.layer.msg(result.msg, {
                                icon:1
                            },
                            function (index, item) {
//                              parent.layer.close(index);
                                location.reload();
                            });
                }
            });
        });
    })
</script>
</body>

</html>
